var arr = [7, 3, 4, 5, 6, 2, 1];
for (var i = 0; i < arr.length; i++) {
  for (var j = i + 1; j < arr.length; j++) {
    if (arr[i] > arr[j]) {
      var temp = arr[i]; //temp = 7
      arr[i] = arr[j]; //arr[i] = 3
      arr[j] = temp; //arr[j] = 7
    }
  }
}
console.log(arr);

// for(初始化值;循环终止条件;递增或递减)
